package com.example.demo01;

import com.alibaba.fastjson.JSON;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.URISyntaxException;

@RestController
public class HelloController {


    @RequestMapping("/")
    public String hello() {

        return "Hello,Spring Boot!你好";
    }

    //key:	825fe12904c410012af61f3da2784af1
    public void crawlerData(
            //String url,
            String addressName) {
        try {
            String url = "http://api.tianditu.gov.cn/geocoder";
            //创建资源路径实例
            URIBuilder uriBuilder = new URIBuilder(url);//url:
            //设置请求参数
            /**
             * http://api.tianditu.gov.cn/geocoder?
             * ds={地名}
             * &tk=825fe12904c410012af61f3da2784af1
             * */
            uriBuilder.setParameter("ds", addressName);
            uriBuilder.setParameter("tk", "825fe12904c410012af61f3da2784af1");


        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }

//    @Test
    public void test1(){
        System.out.println(JSON.toJSONString("{success:true,code:200,date:[]}"));
    }

}
